/*
** init.c for philosophes in /home/cedric/work/cunix/philo/srcs
** 
** Made by Cedric
** Login   <cedric@epitech.net>
** 
** Started on  Wed May  4 16:03:43 2011 Cedric
** Last update Wed May  4 18:06:53 2011 Cedric
*/

#include <stdlib.h>
#include "philo.h"
#include "xmalloc.h"

void		init(t_philo *p)
{
  int		i;
  t_philo	*p2;
  t_philo	*head;
  int		b;

  i = 1;
  b = 5;
  head = p;
  p->p = 0;
  p->g = plein;
  p->d = plein;
  p->j = 100;
  p->prev = NULL;
  while (i < 7)
    {
      p2 = xmalloc(sizeof(t_philo));
      p2->p = i;
      p2->g = vide;
      p2->d = vide;
      p2->head = head;
      if (b)
	{
	  p2->g = plein;
	  b--;
	}
      if (b)
	{
	  p2->d = plein;
	  b--;
	}
      p2->j = 100;
      p2->prev = p;
      p->next = p2;
      p = p2;
      i++;
    }
}
